/**
    ******************************************************************************
    * @file    async_queue_interner.h
    * @author  debian
    * @version V1.0.0
    * @date    2020-07-29
    * @brief   互斥+信号量
    ******************************************************************************
    * @attention
    *
    *
    ******************************************************************************
    */ 

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ASYNC_QUEUE_INTERNER_H
#define __ASYNC_QUEUE_INTERNER_H

#ifdef __cplusplus
    extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "queue.h"
#include <pthread.h>

/** @addtogroup DataStruct_Driver
    * @{
    */

/** @addtogroup async_cond_queue
    * @{
    */

/* Exported types ------------------------------------------------------------*/
/** @defgroup 
    * @{
    */ 
typedef struct async_queue_s
{
    queue_t *q;

    pthread_mutex_t mutex;
    pthread_cond_t cond;

    int wait_thread;

}async_queue_t;


typedef struct async_queue_op
{
    const char* name; // such as cond, eventfd, lock free and so on.
    async_queue_t* (*create)(int size);
    int  (*push)(async_queue_t* queue, task_t* t);
    task_t* (*pop)(async_queue_t* queue, int timeout);
    void  (*free)(async_queue_t* q);
    int  (*empty)(async_queue_t* q);
    int  (*destory)(async_queue_t* q);
    int (*task_free)(task_t* t);
}async_queue_op_t;

/**
    * @}
    */


/* Exported constants --------------------------------------------------------*/
extern async_queue_op_t async_cond_op;

/* Exported macro ------------------------------------------------------------*/

/* Exported functions --------------------------------------------------------*/ 
/* Initialization and de-initialization functions *******************************/
/** @addtogroup async_cond_queue_Exported_Functions
    * @{
    */

/** @addtogroup async_cond_queue_Exported_Functions_Group1
    * @{
    */

/**
    * @}
    */

/* operation functions *******************************************************/
/** @addtogroup async_cond_queue_Exported_Functions_Group2
    * @{
    */



/**
    * @}
    */

/**
    * @}
    */ 

/**
    * @}
    */

/**
    * @}
    */


#ifdef __cplusplus
}
#endif

#endif /* __ASYNC_QUEUE_INTERNER_H */

/******************* (C) 2020 HOME 深圳龙华 *****END OF FILE****/

